var e = require("../../utils/config"), o = require("../../utils/map-convert"), t = require("../../utils/request"), a = require("../../utils/api"), n = require("../../utils/date");

Page({
    data: {
        themeColor: getApp().globalData.themeColor,
        showButton: !1,
        options: {},
        imgUrl: e.resourceRoot + "registerOnMobile.png",
        showMessage: ""
    },
    onLoad: function(e) {
        var s = this;
        wx.showLoading({
            title: "验证中...",
            mask: !0
        }), wx.getLocation({
            type: "gcj02",
            success: function(i) {
                var r = o.qqMapToBMap(i.longitude, i.latitude), c = e.resvNo, l = e.storeNo, u = e.resvStatus, g = e.packageId, p = e.name, d = e.certNo, h = n.formatDate(new Date(e.resvDate), "yyyy-MM-dd"), f = e.applicants, w = e.hasUpgradePackage;
                t.request(t.HttpMethod.POST, a.apiRoute.checkByApplet, {
                    resvNo: c,
                    insCode: l,
                    resvStatus: u,
                    packageId: g,
                    applicants: f,
                    name: p,
                    certNo: d,
                    resvDate: h,
                    hasUpgradePackage: w,
                    latitude: r[1],
                    longitude: r[0]
                }).then(function(o) {
                    wx.hideLoading(), o.data ? s.setData({
                        showButton: !0,
                        options: e,
                        showMessage: "即将跳转“瑞慈电子导引单”小程序，为您开启本次体检之旅，请放心打开"
                    }) : s.setData({
                        showMessage: o.message
                    });
                });
            },
            fail: function(e) {
                console.log("微信获取位置信息失败：" + e.errMsg), e.errMsg.indexOf("频繁") > -1 ? console.log("请勿频繁定位") : wx.showModal({
                    title: "提示",
                    content: "如果您想要从小程序进行登记，可点击小程序右上角“···”，设置中允许使用位置信息，并重新进入小程序",
                    showCancel: !1
                });
            }
        });
    },
    toFrontCheckMiniProgram: function() {
        console.log(this.data.options), wx.navigateToMiniProgram({
            appId: e.checkAppletAppid,
            path: "pages/index/index?type=100&storeNo=" + this.data.options.storeNo + "&resvNo=" + this.data.options.resvNo,
            success: function(e) {
                console.log(e), wx.navigateBack({
                    delta: 1
                });
            },
            fail: function(e) {
                console.log(e), wx.navigateBack({
                    delta: 1
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});